package com.yang.demo.entity;

import com.yang.demo.constants.ResponseCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;



/**
 * 公共返回对象
 * @author xiaoyang
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value="公共的返回对象", description="")
public class RespBean implements ResponseCode {

    @ApiModelProperty(value = "状态码")
    private Integer code;
    @ApiModelProperty(value = "提示信息")
    private String message;
    @ApiModelProperty(value = "对象")
    private Object obj;

    //封装成功的返回对象
    public static RespBean success(String message){
        return new RespBean(SUCCESS,message,null);

    }

    //封装成功的返回对象
    public static RespBean success(String message,Object obj){
        return new RespBean(SUCCESS,message,obj);
    }

    //封装成功的返回对象
    public static RespBean error(String message){
        return new RespBean(ERROR,message,null);
    }

    //封装成功的返回对象
    public static RespBean error(String message,Object obj){
        return new RespBean(ERROR,message,obj);
    }
}
